package online.longzipeng.householdbillssystem.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: lzp
 * @Date: 2021/2/7 15:47
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    /**
     * 接口总描述
     * @return
     */
    private ApiInfo adminApiInfo() {

        return new ApiInfoBuilder()
                .title("家庭账单系统-API文档")
                .description("本文档描述了后台管理系统接口定义")
                .version("1.0")
                .contact(new Contact("龙子彭", "http://www.longzipeng.online", "longzipeng@foxmail.com"))
                .build();
    }

    @Bean
    public Docket adminApiConfig() {

        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("账单管理系统")
                .apiInfo(adminApiInfo())
                .select()
                //显示所有路径的接口
                .paths(PathSelectors.any())
                .build();

    }
}
